home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: thinkage.on.ca!atbowler
- From: atbowler@thinkage.on.ca (Alan Bowler)
- Subject: Re: How do I sort a large Array?
- Message-ID: <Dn8vI4.D8D@thinkage.on.ca>
- Sender: news@thinkage.on.ca
- Organization: Thinkage Ltd.
- References: <4g1kr1$kg1@rznews.rrze.uni-erlangen.de> <4giec7INN1sc@keats.ugrad.cs.ubc.ca>
- Date: Fri, 23 Feb 1996 19:58:52 GMT
-
- In article <4giec7INN1sc@keats.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
- >In article <4g1kr1$kg1@rznews.rrze.uni-erlangen.de>,
- >Matthias Gessl (CIP 95) <msgessl@cip.informatik.uni-erlangen.de> wrote:
- > >How do I sort a large array of char-arrays, which is too large to fit in
- > >memory?
- > >For example I want to sort an array of >10000 elements, but have only RAM
- > >for about 500 elements
- > >
- > >Many thanks in advance.
- >
- >You sort from one file to another. Create N sorted segments (files) that are as
- >large as possible, using available memory. Then merge them together.
- >
- >A good textbook on filesystems and database management should outline
- >techniques for sorting large files using a polyphase merge.
-
- Before you go to all that work, first check the documentation for
- utility programs on your system. There is usually a utility
- sort that will do a disk based sort for you. On the older mainframe
- systems the utility sorts will even have a method of writing your
- own compare code although that is very seldom needed. Internally these
- will use some form of merge sort (polyphase, cascade etc), but you
- can ignore that and treat it as a black box.
-